package com.mine.frame.mylandemo.mvp.presenter

import com.mine.frame.common.base.BasePresenter
import com.mine.frame.mylandemo.entity.forick.ControlBean
import com.mine.frame.mylandemo.mvp.iview.IPanel3In1
import com.third.device.mg.serialport.MGSerialPort
import com.third.device.mg.serialport.factory.forick.product.PanelUART
import com.third.device.mg.serialport.utils.toHexString
import com.third.device.mg.serialport.utils.toUInt16H

fun Byte.toIntFF():Int{
    return this.toInt() and 0xff
}
/**
 * company 广东玛格家居有限公司
 * @author smoker
 * @Date 2021/12/27
 * Description:
 */
class Panel3In1Presenter(mIView: IPanel3In1) : BasePresenter<IPanel3In1>(mIView) {

    /**
     * 创建控制数据
     */
    fun createControlData(){
//*****************空调设备*************************************************************************************
        val list = mutableListOf<ControlBean>()
        list.add(ControlBean(true ,"空调指令" ))

        //空调关机
        val offAir = ControlBean(false ,"空调-关机" ,true)
        offAir.command = MGSerialPort.instance.getForick().panel3In1().onOffAir(mIView.getAddress() ,false)
        offAir.readHLR = PanelUART.HLR_ON_OFF_AIR
        list.add(offAir)

        //空调开机
        val onAir = ControlBean(false ,"空调-开机",true)
        onAir.command = MGSerialPort.instance.getForick().panel3In1().onOffAir(mIView.getAddress() ,true)
        list.add(onAir)

        //空调工作模式:制冷
        val workCold = ControlBean(false ,"空调-模式-制冷",true)
        workCold.command = MGSerialPort.instance.getForick().panel3In1().changeModeAir(mIView.getAddress() ,0)
        workCold.readHLR = PanelUART.HLR_WORK_MODE_AIR
        list.add(workCold)

        //空调工作模式:制热
        val workHot = ControlBean(false ,"空调-模式-制热",true)
        workHot.command = MGSerialPort.instance.getForick().panel3In1().changeModeAir(mIView.getAddress() ,1)
        list.add(workHot)

        //空调工作模式:除湿
        val workWet = ControlBean(false ,"空调-模式-除湿",true)
        workWet.command = MGSerialPort.instance.getForick().panel3In1().changeModeAir(mIView.getAddress() ,2)
        list.add(workWet)

        //空调工作模式:送风
        val workWind = ControlBean(false ,"空调-模式-送风",true)
        workWind.command = MGSerialPort.instance.getForick().panel3In1().changeModeAir(mIView.getAddress() ,3)
        list.add(workWind)

        //空调风速:自动
        val windAuto = ControlBean(false ,"空调-风速-自动",true)
        windAuto.command = MGSerialPort.instance.getForick().panel3In1().changeWindModeAir(mIView.getAddress() ,0)
        windAuto.readHLR = PanelUART.HLR_WIND_MODE_AIR
        list.add(windAuto)

        //空调风速:低速
        val windLow = ControlBean(false ,"空调-风速-低速",true)
        windLow.command = MGSerialPort.instance.getForick().panel3In1().changeWindModeAir(mIView.getAddress() ,1)
        list.add(windLow)

        //空调风速:中速
        val windCenter = ControlBean(false ,"空调-风速-中速",true)
        windCenter.command = MGSerialPort.instance.getForick().panel3In1().changeWindModeAir(mIView.getAddress() ,2)
        list.add(windCenter)

        //空调风速:高速
        val windHigh = ControlBean(false ,"空调-风速-高速",true)
        windHigh.command = MGSerialPort.instance.getForick().panel3In1().changeWindModeAir(mIView.getAddress() ,3)
        list.add(windHigh)

        //空调温度 16℃ ~ 30℃
        for (temp in 16..30){
            val tempControl = ControlBean(false ,"空调-温度-$temp℃",true)
            tempControl.command = MGSerialPort.instance.getForick().panel3In1().setTemperatureAir(mIView.getAddress() ,temp)
            if (temp == 16 ){
                tempControl.readHLR = PanelUART.HLR_TEMP_AIR
            }
            list.add(tempControl)
        }

        //空调阀控制--阀无效-默认
        val valveDef = ControlBean(false ,"空调-阀-无效(默认)")
        valveDef.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeAir(mIView.getAddress() ,0 ,0)
        list.add(valveDef)

        //一路双线阀-关
        val valve12Off = ControlBean(false ,"空调-一路双线阀-关")
        valve12Off.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeAir(mIView.getAddress() ,1 ,0)
        list.add(valve12Off)

        //一路双线阀-开
        val valve12On = ControlBean(false ,"空调-一路双线阀-开")
        valve12On.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeAir(mIView.getAddress() ,1 ,1)
        list.add(valve12On)

        //一路三线阀-关
        val valve13Off = ControlBean(false ,"空调-一路三线阀-关")
        valve13Off.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeAir(mIView.getAddress() ,2 ,0)
        list.add(valve13Off)

        //一路三线阀-开
        val valve13On = ControlBean(false ,"空调-一路三线阀-开")
        valve13On.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeAir(mIView.getAddress() ,2 ,1)
        list.add(valve13On)

        //两路三线冷阀-关
        val valve23coldOff = ControlBean(false ,"空调-两路三线阀-冷阀-关")
        valve23coldOff.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeAir(mIView.getAddress() ,3 ,0)
        list.add(valve23coldOff)

        //两路三线冷阀-开
        val valve23coldOn = ControlBean(false ,"空调-两路三线阀-冷阀-开")
        valve23coldOn.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeAir(mIView.getAddress() ,3 ,1)
        list.add(valve23coldOn)

        //两路三线热阀-关
        val valve23HotOff = ControlBean(false ,"空调-两路三线阀-热阀-关")
        valve23HotOff.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeAir(mIView.getAddress() ,3 ,2)
        list.add(valve23HotOff)

        //两路三线热阀-开
        val valve23HotOn = ControlBean(false ,"空调-两路三线阀-热阀-开")
        valve23HotOn.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeAir(mIView.getAddress() ,3 ,3)
        list.add(valve23HotOn)


//*****************地暖设备*************************************************************************************
        list.add(ControlBean(true ,"地暖指令"))

        //地暖关机
        val floorOff = ControlBean(false ,"地暖-关机",true)
        floorOff.command = MGSerialPort.instance.getForick().panel3In1().onOffFloor(mIView.getAddress() ,false)
        floorOff.readHLR = PanelUART.HLR_ON_OFF_FLOOR
        list.add(floorOff)

        //地暖开机
        val floorOn = ControlBean(false ,"地暖-开机",true)
        floorOn.command = MGSerialPort.instance.getForick().panel3In1().onOffFloor(mIView.getAddress() ,true)
        list.add(floorOn)

        //地暖温度 16℃ ~ 30℃
        for (temp in 16..30){
            val tempControl = ControlBean(false ,"地暖-温度-$temp℃",true)
            tempControl.command = MGSerialPort.instance.getForick().panel3In1().setTemperatureFloor(mIView.getAddress() ,temp)
            if (temp == 16){
                tempControl.readHLR = PanelUART.HLR_TEMP_FLOOR
            }
            list.add(tempControl)
        }

        //地暖-阀无效-默认
        val valveDefFloor = ControlBean(false ,"地暖-阀无效-默认")
        valveDefFloor.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeFloor(mIView .getAddress(),0 ,0)
        list.add(valveDefFloor)

        //地暖-一路双线阀-关
        val valve12OffFloor = ControlBean(false ,"地暖-一路双线阀-关")
        valve12OffFloor.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeFloor(mIView .getAddress(),1 ,0)
        list.add(valve12OffFloor)

        //地暖-一路双线阀-开
        val valve12OnFloor = ControlBean(false ,"地暖-一路双线阀-开")
        valve12OnFloor.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeFloor(mIView .getAddress(),1 ,1)
        list.add(valve12OnFloor)

        //地暖-一路三线阀-关
        val valve13OffFloor = ControlBean(false ,"地暖-一路三线阀-关")
        valve13OffFloor.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeFloor(mIView .getAddress(),2 ,0)
        list.add(valve13OffFloor)

        //地暖-一路三线阀-开
        val valve13OnFloor = ControlBean(false ,"地暖-一路三线阀-开")
        valve13OnFloor.command = MGSerialPort.instance.getForick().panel3In1().changeValveModeFloor(mIView .getAddress(),2 ,1)
        list.add(valve13OnFloor)

//*****************新风设备*************************************************************************************
        list.add(ControlBean(true ,"新风指令"))

        //新风-关机
        val windOff = ControlBean(false ,"新风-关机" ,true)
        windOff.command = MGSerialPort.instance.getForick().panel3In1().onOffWind(mIView.getAddress() ,false)
        windOff.readHLR = PanelUART.HLR_ON_OFF_WIND
        list.add(windOff)

        //新风-开机
        val windOn = ControlBean(false ,"新风-开机" ,true)
        windOn.command = MGSerialPort.instance.getForick().panel3In1().onOffWind(mIView.getAddress() ,true)
        list.add(windOn)

        //新风-风速-风机关闭
        val windModeClose = ControlBean(false ,"新风-风速-风机关闭",true)
        windModeClose.command = MGSerialPort.instance.getForick().panel3In1().changeWindModeWind(mIView.getAddress() ,0)
        windModeClose.readHLR = PanelUART.HLR_WIND_MODE_WIND
        list.add(windModeClose)

        //新风-风速-风机低速
        val windModeLow = ControlBean(false ,"新风-风速-低速",true)
        windModeLow.command = MGSerialPort.instance.getForick().panel3In1().changeWindModeWind(mIView.getAddress() ,1)
        list.add(windModeLow)

        //新风-风速-风机中速
        val windModeCenter = ControlBean(false ,"新风-风速-中速",true)
        windModeCenter.command = MGSerialPort.instance.getForick().panel3In1().changeWindModeWind(mIView.getAddress() ,2)
        list.add(windModeCenter)

        //新风-风速-风机高速
        val windModeHigh = ControlBean(false ,"新风-风速-高速",true)
        windModeHigh.command = MGSerialPort.instance.getForick().panel3In1().changeWindModeWind(mIView.getAddress() ,3)
        list.add(windModeHigh)

//*****************环境参数(被动)*************************************************************************************
        list.add(ControlBean(true ,"环境参数(被动)"))

        //补偿温度 -9℃ ~ 9℃
        for (temp in -9..9){
            val offsetControl = ControlBean(false ,"补偿温度-($temp℃)" ,true)
            offsetControl.command = MGSerialPort.instance.getForick().panel3In1().temperatureOffset(mIView.getAddress() ,temp)
            if (temp == -9){
                offsetControl.readHLR = PanelUART.HLR_OFFSET_TEMP_ENVIRONMENT
            }
            list.add(offsetControl)
        }

        //实时温度
        val nowTemp = ControlBean(false ,"实时温度" , true)
        nowTemp.readHLR = PanelUART.HLR_REAL_TIME_TEMP_ENVIRONMENT
        list.add(nowTemp)

        //实时湿度
        val nowHumidity = ControlBean(false ,"实时湿度" , true)
        nowHumidity.readHLR = PanelUART.HLR_REAL_TIME_HUMIDITY_ENVIRONMENT
        list.add(nowHumidity)

        //新风实时参数
        val nowParamWind = ControlBean(false ,"新风实时参数" , true)
        list.add(nowParamWind)

//*****************面板辅助数据(被动)*************************************************************************************
        list.add(ControlBean(true ,"面板辅助数据(被动)"))

        //空调继电器-无效
        val airRelayInvalid = ControlBean(false ,"空调继电器-无效")
        airRelayInvalid.command = MGSerialPort.instance.getForick().panel3In1().setAirRelayControlMode(mIView.getAddress() ,0 ,0)
        list.add(airRelayInvalid)

        //空调继电器-自控-一路双线阀或一路三线阀（一控）默认
        val airRelayAuto12or3 = ControlBean(false ,"空调继电器-自控-一路双线阀或一路三线阀（一控）默认")
        airRelayAuto12or3.command = MGSerialPort.instance.getForick().panel3In1().setAirRelayControlMode(mIView.getAddress() ,1 ,1)
        list.add(airRelayAuto12or3)

        //空调继电器-自控-一路三线阀（二控）
        val airRelayAuto13 = ControlBean(false ,"空调继电器-自控-一路三线阀（二控）")
        airRelayAuto13.command = MGSerialPort.instance.getForick().panel3In1().setAirRelayControlMode(mIView.getAddress() ,1 ,2)
        list.add(airRelayAuto13)

        //空调继电器-自控-两路双线阀或一路三线阀（一控）
        val airRelayAuto23or13 = ControlBean(false ,"空调继电器-自控-两路双线阀或一路三线阀（一控）")
        airRelayAuto23or13.command = MGSerialPort.instance.getForick().panel3In1().setAirRelayControlMode(mIView.getAddress() ,1 ,3)
        list.add(airRelayAuto23or13)


        //空调继电器-被控-一路双线阀或一路三线阀（一控）默认
        val airRelay12or3 = ControlBean(false ,"空调继电器-被控-一路双线阀或一路三线阀（一控）默认")
        airRelay12or3.command = MGSerialPort.instance.getForick().panel3In1().setAirRelayControlMode(mIView.getAddress() ,2 ,1)
        list.add(airRelay12or3)

        //空调继电器-被控-一路三线阀（二控）
        val airRelay13 = ControlBean(false ,"空调继电器-被控-一路三线阀（二控）")
        airRelay13.command = MGSerialPort.instance.getForick().panel3In1().setAirRelayControlMode(mIView.getAddress() ,2 ,2)
        list.add(airRelay13)

        //空调继电器-被控-两路双线阀或一路三线阀（一控）
        val airRelay23or13 = ControlBean(false ,"空调继电器-被控-两路双线阀或一路三线阀（一控）")
        airRelay23or13.command = MGSerialPort.instance.getForick().panel3In1().setAirRelayControlMode(mIView.getAddress() ,2 ,3)
        list.add(airRelay23or13)



        //地暖继电器-无效
        val floorRelayInvalid = ControlBean(false ,"地暖继电器-无效")
        floorRelayInvalid.command = MGSerialPort.instance.getForick().panel3In1().setFloorRelayControlMode(mIView.getAddress() ,0 ,0)
        list.add(floorRelayInvalid)

        //地暖继电器-自控-一路双线阀或一路三线阀（一控）默认
        val floorRelayAuto12or3 = ControlBean(false ,"地暖继电器-自控-一路双线阀或一路三线阀（一控）默认")
        floorRelayAuto12or3.command = MGSerialPort.instance.getForick().panel3In1().setFloorRelayControlMode(mIView.getAddress() ,1 ,1)
        list.add(floorRelayAuto12or3)

        //地暖继电器-自控-一路三线阀（二控）
        val floorRelayAuto13 = ControlBean(false ,"地暖继电器-自控-一路三线阀（二控）")
        floorRelayAuto13.command = MGSerialPort.instance.getForick().panel3In1().setFloorRelayControlMode(mIView.getAddress() ,1 ,2)
        list.add(floorRelayAuto13)


        //地暖继电器-被控-一路双线阀或一路三线阀（一控）默认
        val floorRelay12or3 = ControlBean(false ,"地暖继电器-被控-一路双线阀或一路三线阀（一控）默认")
        floorRelay12or3.command = MGSerialPort.instance.getForick().panel3In1().setFloorRelayControlMode(mIView.getAddress() ,2 ,1)
        list.add(floorRelay12or3)

        //地暖继电器-被控-一路三线阀（二控）
        val floorRelay13 = ControlBean(false ,"地暖继电器-被控-一路三线阀（二控）")
        floorRelay13.command = MGSerialPort.instance.getForick().panel3In1().setFloorRelayControlMode(mIView.getAddress() ,2 ,2)
        list.add(floorRelay13)


        //新风继电器-无效
        val windRelayUnInvalid = ControlBean(false ,"新风继电器-无效")
        windRelayUnInvalid.command = MGSerialPort.instance.getForick().panel3In1().setWindRelayControlMode(mIView.getAddress() ,0)
        list.add(windRelayUnInvalid)

        //新风继电器-有效
        val windRelayInvalid = ControlBean(false ,"新风继电器-有效")
        windRelayInvalid.command = MGSerialPort.instance.getForick().panel3In1().setWindRelayControlMode(mIView.getAddress() ,1)
        list.add(windRelayInvalid)

        //低温保护
        for (temp in 0..5){
            val lowTemp = ControlBean(false ,"低温保护阀值:$temp℃" ,true)
            lowTemp.command = MGSerialPort.instance.getForick().panel3In1().lowTemperatureProtection(mIView.getAddress() ,temp)
            if (temp == 0){
                lowTemp.readHLR = PanelUART.HLR_LOW_TEMP_DISC_PANEL
            }
            list.add(lowTemp)
        }

        //取消低温保护
        val lowTemp = ControlBean(false ,"低温保护阀值:取消低温保护",true)
        lowTemp.command = MGSerialPort.instance.getForick().panel3In1().lowTemperatureProtection(mIView.getAddress() ,15)
        list.add(lowTemp)


        //面板是否上锁
        for (lock in 0..1){
            val title = if (lock == 0) "面板解锁(默认)" else "面板上锁"
            val lockControl = ControlBean(false ,title ,true)
            lockControl.command = MGSerialPort.instance.getForick().panel3In1().onOffLock(mIView.getAddress() ,lock == 1)
            if (lock == 0){
                lockControl.readHLR = PanelUART.HLR_LOCK_PANEL
            }
            list.add(lockControl)
        }

        //面板上锁模式
        for (lock in 0..1){
            val title = if (lock == 0) "面板半锁模式:锁定面板时不锁开关键(默认)" else "面板全锁模式:锁定面板时锁定开关键"
            val lockControl = ControlBean(false ,title ,true)
            lockControl.command = MGSerialPort.instance.getForick().panel3In1().lockMode(mIView.getAddress() ,lock == 1)
            if (lock == 0){
                lockControl.readHLR = PanelUART.HLR_LOCK_MODE_PANEL
            }
            list.add(lockControl)
        }

        //数据上报模式
        for (data in 0..1){
            val title = if (data == 0) "数据上报模式:主动模式" else "数据上报模式:被动模式"
            val dataMode = ControlBean(false ,title ,true)
            dataMode.command = MGSerialPort.instance.getForick().panel3In1().dataReportMain(mIView.getAddress() ,data == 0)
            if (data == 0){
                dataMode.readHLR = PanelUART.HLR_DATA_REPORT_PANEL
            }
            list.add(dataMode)
        }

        //按键指示灯:低亮4%
        for (level in 0..6){
            val title = if (level == 0) "自动" else "${level * 10 + 25 }%"
            val key = ControlBean(false ,"按键指示灯:低亮(4%) -- $title" ,true)
            key.command = MGSerialPort.instance.getForick().panel3In1().keyLampLevel(mIView.getAddress() ,0 ,level)
            if (level == 0){
                key.readHLR = PanelUART.HLR_INDICATOR_LIGHTNESS_PANEL
            }
            list.add(key)
        }

        //按键指示灯:低亮0%
        for (level in 0..6){
            val title = if (level == 0) "自动" else "${level * 10 + 25 }%"
            val key = ControlBean(false ,"按键指示灯:低亮(0%) -- $title" ,true)
            key.command = MGSerialPort.instance.getForick().panel3In1().keyLampLevel(mIView.getAddress() ,1 ,level)
            list.add(key)
        }

        //光照等级
        for (level in 1..6){
            val lx = ControlBean(false ,"光照等级: $level 级" ,true)
            lx.command = MGSerialPort.instance.getForick().panel3In1().illuminanceLevel(mIView.getAddress() ,level)
            if (level == 1){
                lx.readHLR = PanelUART.HLR_LUX_LEVEL_PANEL
            }
            list.add(lx)
        }

        //休眠时间
        for (time in 0..6){
            val title = if (time == 0) "休眠时间:30秒" else if (time == 6) "不休眠" else "休眠时间:${time}分钟"
            val sleep = ControlBean(false ,title ,true)
            if (time != 6){
                sleep.command = MGSerialPort.instance.getForick().panel3In1().sleepBacklight(mIView.getAddress() ,time)
            }else{
                sleep.command = MGSerialPort.instance.getForick().panel3In1().sleepBacklight(mIView.getAddress() ,15)
            }
            if (time == 0){
                sleep.readHLR = PanelUART.HLR_LIGHT_SLEEP_PANEL
            }
            list.add(sleep)
        }

        //获取当前面板版本号
        val verControlBean = ControlBean(false ,"获取版本号" ,true)
        verControlBean.command = MGSerialPort.instance.getForick().panel3In1().getPanelVersion(mIView.getAddress())
        verControlBean.readHLR = PanelUART.HLR_VERSION_PANEL
        list.add(verControlBean)

        mIView.initControlList(list)
    }


    /**
     * 解析服务器下发的数据
     * 只适用于读取单个及寄存器的解析
     */
    fun analysisReadMsg(result: ByteArray){
        if (null == mIView.getReadHLRAddress() || result.size < 7 || result[1].toIntFF() != 3){
            return
        }
        val v3 = result[3]
        val v4 = result[4]
        val msg :String
        when(mIView.getReadHLRAddress()){
            PanelUART.HLR_ON_OFF_AIR ->{//空调开关状态
                msg = if (v4.toIntFF() == 0){
                    "空调是关闭状态"
                }else{
                    "空调是开启状态"
                }
            }
            PanelUART.HLR_WORK_MODE_AIR ->{//空调模式
                msg = when (v4.toIntFF()){
                    0 -> {
                        "空调制冷模式"
                    }
                    1 -> {
                        "空调制热模式"
                    }
                    2 -> {
                        "空调除湿模式"
                    }
                    else -> {
                        "空调送风模式"
                    }
                }
            }
            PanelUART.HLR_WIND_MODE_AIR ->{//空调风速
                msg = if (v3.toIntFF() == 0 && v4.toIntFF() == 1){
                    "空调风速-低速"
                }else if (v3.toIntFF() == 0 && v4.toIntFF() == 2){
                    "空调风速-中速"
                }else if (v3.toIntFF() == 0 && v4.toIntFF() == 3){
                    "空调风速-高速"
                }else if (v3.toIntFF() == 1 && v4.toIntFF() == 0){
                    "空调风速-自动"
                }else{
                    "空调风速-未知"
                }
            }
            PanelUART.HLR_TEMP_AIR ->{//空调温度
                msg = "空调温度:${v4.toIntFF()}℃"
            }
            PanelUART.HLR_ON_OFF_FLOOR ->{//地暖开关
                msg = if (v4.toIntFF() == 0){
                    "地暖是关闭状态"
                }else{
                    "地暖是开启状态"
                }
            }
            PanelUART.HLR_TEMP_FLOOR ->{
                msg = "地暖温度:${v4.toIntFF()}℃"
            }
            PanelUART.HLR_ON_OFF_WIND ->{
                msg = if (v4.toIntFF() == 0){
                    "新风是关闭状态"
                }else{
                    "新风是开启状态"
                }
            }
            PanelUART.HLR_WIND_MODE_WIND ->{
                msg = when (v4.toIntFF()){
                    0 -> {
                        "新风:风机关闭"
                    }
                    1 -> {
                        "新风:低速"
                    }
                    2 -> {
                        "新风:中速"
                    }
                    3 -> {
                        "新风:高速"
                    }
                    else -> {
                        "新风:未知"
                    }
                }
            }
            PanelUART.HLR_OFFSET_TEMP_ENVIRONMENT ->{
                msg = "补偿温度为:${v4.toInt()}℃"
            }
            PanelUART.HLR_REAL_TIME_TEMP_ENVIRONMENT ->{
                val temp = byteArrayOf(v3 ,v4).toUInt16H()
                msg = if (temp > 600){
                    "当前实时温度:${temp - 4096 }℃"
                }else{
                    "当前实时温度:${temp.toDouble() / 10}℃"
                }
            }
            PanelUART.HLR_REAL_TIME_HUMIDITY_ENVIRONMENT ->{
                msg = "当前实时湿度:${v4.toInt()}%"
            }
            PanelUART.HLR_LOW_TEMP_DISC_PANEL ->{
                msg = if (v4.toIntFF() == 15){
                    "未开启低温保护"
                }else{
                    "当前低温保护阀值:${v4.toIntFF()}℃"
                }
            }
            PanelUART.HLR_LOCK_PANEL ->{
                msg = if (v4.toIntFF() == 0){
                    "面板未上锁"
                }else{
                    "面板锁定中"
                }
            }
            PanelUART.HLR_LOCK_MODE_PANEL ->{
                msg = if (v4.toIntFF() == 0){
                    "面板为半锁模式"
                }else{
                    "面板为全锁模式"
                }
            }
            PanelUART.HLR_DATA_REPORT_PANEL ->{
                msg = if (v4.toIntFF() == 0){
                    "数据主动上报模式"
                }else{
                    "数据被动上报模式"
                }
            }
            PanelUART.HLR_INDICATOR_LIGHTNESS_PANEL ->{
                val mode = if (v3.toIntFF() == 0){
                    "按键低亮(4%)模式 -- "
                }else{
                    "按键熄灭(0%)模式 -- "
                }
                val state  = when(v4.toIntFF()){
                    0 ->{
                        "自动"
                    }
                    1 ->{
                        "35%"
                    }
                    2 ->{
                        "45%"
                    }
                    3 ->{
                        "55%"
                    }
                    4 ->{
                        "65%"
                    }
                    5 ->{
                        "75%"
                    }
                    else ->{
                        "85%"
                    }
                }
                msg = mode + state
            }
            PanelUART.HLR_LUX_LEVEL_PANEL ->{
                msg = "光照等级: ${v4.toIntFF()}级"
            }
            PanelUART.HLR_LIGHT_SLEEP_PANEL ->{
                msg  = when(v4.toIntFF()){
                    0 ->{
                        "背光休眠: 30秒"
                    }
                    1,2,3,4,5 ->{
                        "背光休眠: ${v4.toIntFF()}分钟"
                    }
                    15 ->{
                        "背光休眠:不休眠"
                    }
                    else ->{
                        "背光休眠:异常"
                    }
                }
            }
            PanelUART.HLR_VERSION_PANEL ->{
                val major = v3.toIntFF()
                val minor = v4.toIntFF()
                msg = "当前版本:V${major}.${minor}(Hex:${v3.toHexString()} ${v4.toHexString()})"
            }
            else ->{
                msg = "未知异常"
            }

        }

        mIView.showReadMsg(msg)
    }
}